package cn.sinjet.adapter;

import java.util.List;

import com.mgroup.wazehelper.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import cn.sinjet.entity.PID;


public class MyPidListAdapter  extends BaseAdapter {

	private List<PID> m_listData;
	private Context m_context;

	public MyPidListAdapter(Context context, List<PID> pidListData) {

		// TODO Auto-generated constructor stub
		m_context = context;
		m_listData = pidListData;

	}

	@Override
	public View getView(int position, View conVertView, ViewGroup parent) {

		if (conVertView == null) {
			/*
			 * LayoutInflater inflater = (LayoutInflater) m_context
			 * .getSystemService(Context.LAYOUT_INFLATER_SERVICE); conVertView =
			 * inflater.inflate(R.layout.obd_list_item_view, null);
			 */
			conVertView = LayoutInflater.from(m_context).inflate(
					R.layout.pid_list_item_view, null);

		}

		PID item = m_listData.get(position);

		if (item != null) {
			TextView tvName = (TextView) conVertView.findViewById(R.id.pid_tv_name);
			tvName.setText(item.strName);
			
			TextView tvValue = (TextView) conVertView.findViewById(R.id.pid_tv_value);
			tvValue.setText(item.strValue);
		}

		return conVertView;
	}

	public void setListData(List<PID> objects)
	{
		m_listData.clear();
		m_listData = objects;
		notifyDataSetChanged();
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return m_listData.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return m_listData.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}
	
	/*class PID
	{
		public PID()
		{
			strName = "";
			strValue = "";
		}
		
		public String strName;
		public String strValue;
	}*/
	
}

